{block name=student}
	{function name=setstudentclass id="" default=0}{assign var=val value=$default}{if $id neq ""}{foreach from=$student.cartitem_id key=key item=value}{if $id eq $key}{assign var=val value=$value}{break}{/if}{/foreach}{/if}{$val}{/function}
	
	{function name=setstudentclasschk id="" default=0}{assign var=val value=$default}{if $id neq ""}{foreach from=$student.cartitem_id key=key item=value}{if $id eq $key}{assign var=val value=$value}{break}{/if}{/foreach}{/if}{if $val eq 1}checked{/if}{/function}

		{if $cnt}{assign var='cnt' value=$cnt+1}{else}{assign var='cnt' value=1}{/if}
	<div id="student{$cnt}" {if $student.student_id && $trial_flag eq 1}style="display:none;{/if}">
     <input class="student_id" type="hidden" name="student[{$cnt}][student_id]" value="{$student.student_id}" />
     <input type="hidden" name="student[{$cnt}][student_trial_flag]" id="trial{$cnt}" value="{if $student.student_trial_flag}{$student.student_trial_flag}{else}{$trial_flag}{/if}" />
     <div class="form-group">
         <label class="col-sm-3 control-label">姓名</label>
         <div class="col-sm-4">
             <input type="text" value="{$student.student_name}" class="form-control student_name" name="student[{$cnt}][student_name]" >
       </div>
     </div>
     <!-- <div class="form-group">
         <label class="col-sm-3 control-label">名</label>
         <div class="col-sm-4">
             <input type="text" value="{$student.student_surname}" class="form-control student_surname" name="student[{$cnt}][student_surname]" >
       </div>
     </div> -->
     <div class="form-group">
			<label class="col-sm-3 control-label">生日</label>
			<div class="col-sm-4">
				<input class="form-control dates datepicker" type="text" value="{if $student.student_dob && $student.student_dob neq '0000-00-00'}{$student.student_dob|date_format:'%Y-%m-%d'}{/if}" name="from{$cnt}" id="from{$cnt}" onchange="setDateValue('dob{$cnt}',this.value);" >
				<input type="hidden" class="student_dob" value="{$student.student_dob}" name="student[{$cnt}][student_dob]" id="dob{$cnt}">
				<script>
					$(function() {
						$("#from{$cnt}").datepicker({
				 			changeMonth : true,
				 			changeYear : true,
				 			dateFormat : "dd/mm/yy",
				 			onSelect : function(selectedDate) {
				 				$("#dob{$cnt}").val( convert_to_mysql_date_format(selectedDate) );
				 			}
				 		});
					});
				</script>
			</div>
		</div>
		<div class="form-group">
         <label class="col-sm-3 control-label">病史</label>
         <div class="col-sm-4">
             <textarea class="form-control student_medical" name="student[{$cnt}][student_medical]">{$student.student_medical}</textarea>
       </div>
    </div>
    <div class="form-group">
    {foreach $productsOnCart as $item}
    	{if $item.cartitem_class_flag eq 1 && $student.student_id && $item.cartitem_enrolment_type eq 'T'}
    		<div class="text-danger text-center">该学生不需要进行体验课程</div>
    		{break}
    	{/if}
    {/foreach}
	   
	  {assign var='isFirst' value=1}
    {foreach $productsOnCart as $item}
    	{if $item.cartitem_class_flag eq 1 }
    		<label class="col-sm-3 control-label">{if $isFirst}{assign var='isFirst' value=0}给该学生选择一个课程进行报名{/if}</label>
				<div class="col-sm-9">
					<label class="control-label{if $student.student_id && $item.cartitem_enrolment_type eq 'T' } text-danger{/if}" style="text-align:left;">
					{assign var='stdinit' value=0}{if !$student.student_id}{assign var='stdinit' value=1}{/if}
					<input type="hidden" value="{if $selectedStudent[$student.student_id][$item.cartitem_product_id]}1{else}{call name=setstudentclass id=$item.cartitem_id default=$stdinit}{/if}" name="student[{$cnt}][cartitem_id][{$item.cartitem_id}]" class="value" data-available="{$item.availability.available}"> 
					<input class="chckbx" type="checkbox" {if $selectedStudent[$student.student_id][$item.cartitem_product_id]}checked{else}{call name=setstudentclasschk id=$item.cartitem_id default=$stdinit}{/if} name="ct-checkbox" onclick="if($(this).is(':checked')){ $(this).parent().children('.value').val('1') }else{ $(this).parent().children('.value').val('0') }" >
						{if $item.availability.available gt 0}{$item.cartitem_product_name}{else}<span style="text-decoration:line-through;">{$item.cartitem_product_name}</span> <a href="javascript:void(0)" onclick="if(confirm('Do you want to add this student to the wait list?')) AddWaitList({$cnt}, {if $user_id}{$user_id}{else}{$user.user_id}{/if}, {$item.term_object_id}, {$item.class_object_id})">添加到等到列表</a>{/if}
					</label>
				</div>	
			{/if}
		{/foreach}
    </div>
    {if $newmember neq 1}
    <div class=" col-sm-offset-3 error-alert" style="display:none;">
    	<div class="alert alert-danger fade in ">
				<button class="close" aria-hidden="true" type="button" onclick="$(this).closest('.error-alert').fadeOut('slow');">&times;</button>
				<strong></strong>
			</div>
    </div>
		{/if}
		{if $newmember}
 	 	<div class="col-sm-offset-3" >
			<button type="button" class="btn btn-default delete-student-btn" {if !$student.student_id}style="display:none;"{/if} onclick="if(ConfirmDelete())$('#student{$cnt}').hide('slow').html('')">移除</button>
		</div> 
		{/if}
    <hr>
  </div>
{/block} 


